#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int n, k,i,j,sum=0;
	cin>>n>>k;
	int sum1 = pow(2, n);
	for (i = 0; i < sum1;)
	{
		i++;
		int i1 = i;
		j = 0;
		while (i / 2 != 0)
		{
			if (i % 2 == 1)
			{
				j++;
			}
			i /= 2;
		}
		if (j == k)
		{
			sum = 0;
			sum += i1;
		}
	}
	cout << sum << endl;
}